/**
 * $Id: SGIPDeliverRepMessage.java,v 1.1 2006/09/07 02:08:40 martin Exp $
 *
 * Copyright 2005 Skyinfo, Inc. All Rights Reserved.
 */
package com.haoxi.gateway.sgip12msg;

import com.haoxi.gateway.util.TypeConvert;
public class SGIPDeliverRepMessage extends SGIPMessage {

    private String outStr;

    public SGIPDeliverRepMessage(int result) throws IllegalArgumentException {
        if (result < 0 || result > 255) {
            throw new IllegalArgumentException(
                    "The parameter of response message for answering the deliver message sent by SMC is wrong:result less than 0 or larger than 255.");
        } else {
            int len = 29;
            buf = new byte[len];
            TypeConvert.int2byte(len, buf, 0);
            TypeConvert.int2byte(SGIPCommon.SGIP_DELIVER_RESP, buf, 4);
            buf[20] = (byte) result;
            outStr = ",result=".concat(String.valueOf(result));
            return;
        }
    }

    public String toString() {
        String tmpStr=new StringBuffer("SGIP_DELIVER_REP: ")
                .append("Src_node_Id=").append(getSrcNodeId())
                .append(",Time_Stamp=").append(getTimeStamp())
                .append(",Sequence_Id=").append(getSequenceId())
                .append(outStr).toString();
        return tmpStr;
    }

    public int getCommandId() {
        return SGIPCommon.SGIP_DELIVER_RESP;
    }
}
